<layout name='Layout/layout_main' />
<script type="text/javascript">
	function btn_search() {
		sendForm("form_search", "__SELF__");
		$("#form_search").submit();
	}

	function key_search() {
		if (event.keyCode == 13) {
			sendForm("form_search", "__SELF__");
			return false;
		}
	}

	function save() {
		if ($("input:checked[name='emp_id[]']").length < 1) {
			alert("请选择用户");
			return false;
		};
		if ($("input:checked[name='role_list[]']").length < 1) {
			alert("请选择权限");
			return false;
		};
		sendForm("form_data", "{:U('set_role')}");
	}

	function showdata(result) {
		$("input[name='role_list[]']").each(function() {
			$(this).iCheck('uncheck');
		});
		for (var s in result.data) {
			$("#role_" + result.data[s].role_id).iCheck('check');
		}
	}


	$(document).ready(function() {
		set_return_url();
		$(".sub_left_menu tbody tr").click(function() {
			$(".sub_left_menu  tr").attr("class", "");
			$(this).attr("class", "active");
			sendAjax("{:U('get_role_list')}", "id=" + $(this).attr("id"), function(data) {
				showdata(data);
			});
		})
	}); 
</script>
<form method="post" action="" id="form_search" name="form_search">
	<div class="title panel panel-default">
		<div class="panel-body">
			<h3 class="col-md-8">用户管理</h3>
			<div class="col-md-4 pull-right">
				<div class="search_box">
					<div class="input-group ">
						<input  class="form-control" type="text"  onkeydown="key_search();" name="keyword" id="keyword"/>
						<div class="input-group-btn">
							<a class="btn btn-default" onclick="btn_search();" > <i class="icon-search" ></i> </a>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</form>
<div class="operate panel panel-default">
	<div class="panel-body">
		<div class="pull-right">
			<a onclick="save()" class="btn btn-default">保存</a>
		</div>
	</div>
</div>
<!-- 列表显示区域  -->

<div class="row">
	<div class="col-md-8 sub_left_menu">
		<form id="form_data" name="form_data"method="post" >
			<table class="table table-bordered">
				<thead>
					<tr>
						<th class="text-center">
						<input  type="checkbox" id="chk_select_all" value="all" onclick="select_all('emp_id[]')"/>
						</th>
						<th>
						<nobr>
							员工编号
						</nobr></th>
						<th>
						<nobr>
							姓名
						</nobr></th>
						<th>
						<nobr>
							部门
						</nobr></th>
						<th>
						<nobr>
							职级
						</nobr></th>
						<th>
						<nobr>
							职责
						</nobr></th>
						<th>
						<nobr>
							状态
						</nobr></th>
					</tr>
				</thead>
				<tbody>
					<volist name="user_list" id="data">
						<tr id="{$data.id}">
							<td class="text-center">
							<input type="checkbox" name="emp_id[]" value="{$data.id}">
							</td>
							<td>
							<nobr>
								{$data.emp_no}
							</nobr></td>
							<td>
							<nobr>
								{$data.emp_name}
							</nobr></td>
							<td>
							<nobr>
								{$data.dept_name}
							</nobr></td>
							<td>
							<nobr>
								{$data.rank_name}
							</nobr></td>
							<td>
							<nobr>
								{$data.position_name}
							</nobr></td>
							<td>
							<nobr>
								{$data.is_del|status}
							</nobr></td>
						</tr>
					</volist>
				</tbody>
			</table>
	</div>
	<div class="col-md-4 sub_content">
		<input type="hidden" name="id" id="id">
		<input type="hidden" name="pid" id="pid" value="">
		<input type="hidden" name="ajax" id="ajax" value="1">
		<input type="hidden" name="opmode" id="opmode" value="">
		<table class="table table-bordered">
			<thead>
				<tr>
					<th>&nbsp;</th>
					<th>名称</th>
				</tr>
			</thead>
			<tbody>
				<volist name="role_list" id="data">
					<tr id="{$data.id}">
						<td>
						<input type="checkbox" id="role_{$data.id}" name="role_list[]" value="{$data.id}">
						</td>
						<td>{$data.name}</td>
					</tr>
				</volist>
			</tbody>
		</table>
		</form>
	</div>
</div>

